package edu.hgnu.router;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class RouterCustomer {

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(
                            value = "directs",type = "direct"
                    ),
                    key = {
                            "error","info","warning","debug"
                    }
            )
    })
    public void test(String msg){
        System.out.println("all信息msg1="+msg);
    }

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(
                            value = "directs",type = "direct"
                    ),
                    key = {
                            "error"
                    }
            )
    })
    public void test2(String msg){
        System.out.println("只接受错误信息msg2="+msg);
    }

    /**
     *
     * @param msg
     */
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(
                            value = "directs",type = "direct"
                    ),
                    key = {
                            "info"
                    }
            )
    })
    public void test3(String msg){
        System.out.println("只接受info信息msg3="+msg);
    }
}
